package com.example.j202411.views.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.j202411.R;
import com.example.j202411.databinding.FragmentToolsBinding;
import com.example.j202411.views.Activity.BusLineActivity;
import com.example.j202411.views.Activity.CatalogACtivity;
import com.example.j202411.views.Activity.ConstellationActivity;
import com.example.j202411.views.Activity.MovieActivity;
import com.example.j202411.views.Activity.TopNewsActivity;
import com.example.j202411.views.Activity.TranslateActivity;
import com.example.j202411.views.Activity.Weather;


public class FragmentTools  extends Fragment implements View.OnClickListener{

    private FragmentToolsBinding binding;

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        InitView();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragmentToolsBinding.inflate(getLayoutInflater());
        return binding.getRoot();
    }

    private void InitView(){
        binding.tianqi.setOnClickListener(this);
        binding.topnews.setOnClickListener(this);
        binding.tushu.setOnClickListener(this);
        binding.fanyi.setOnClickListener(this);
        binding.zidian.setOnClickListener(this);
        binding.tabG.setOnClickListener(this);
        binding.tabI.setOnClickListener(this);
        binding.tabJ.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        int id =v.getId();
        if (id == R.id.tianqi){
            Intent intent =new Intent(getActivity(), Weather.class);
            startActivity(intent);
        } else if (id ==R.id.topnews) {
            Intent intent =new Intent(getActivity(), TopNewsActivity.class);
            startActivity(intent);
        } else if (id==R.id.tushu) {
            Intent intent =new Intent(getActivity(), CatalogACtivity.class);
            startActivity(intent);
        }else if (id==R.id.fanyi) {
            Intent intent =new Intent(getActivity(), TranslateActivity.class);
            startActivity(intent);
        }else if (id==R.id.tabG) {
            Intent intent =new Intent(getActivity(), MovieActivity.class);
            startActivity(intent);
        }else if (id==R.id.tabI) {
            Intent intent =new Intent(getActivity(), BusLineActivity.class);
            startActivity(intent);
        }else if (id==R.id.tabJ) {
            Intent intent =new Intent(getActivity(), ConstellationActivity.class);
            startActivity(intent);
        }

    }
}
